<?php

/**
 * Chronicle filter form base class.
 *
 * @package    rpgcom
 * @subpackage filter
 * @author     Your name here
 */
abstract class BaseChronicleFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'description'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'idStoryteller' => new sfWidgetFormPropelChoice(array('model' => 'User', 'add_empty' => true)),
      'idSupplement'  => new sfWidgetFormPropelChoice(array('model' => 'Supplement', 'add_empty' => true)),
      'dtIni'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'dtEnd'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'name'          => new sfValidatorPass(array('required' => false)),
      'description'   => new sfValidatorPass(array('required' => false)),
      'idStoryteller' => new sfValidatorPropelChoice(array('required' => false, 'model' => 'User', 'column' => 'idUser')),
      'idSupplement'  => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Supplement', 'column' => 'idSupplement')),
      'dtIni'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'dtEnd'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('chronicle_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Chronicle';
  }

  public function getFields()
  {
    return array(
      'idChronicle'   => 'Number',
      'name'          => 'Text',
      'description'   => 'Text',
      'idStoryteller' => 'ForeignKey',
      'idSupplement'  => 'ForeignKey',
      'dtIni'         => 'Date',
      'dtEnd'         => 'Date',
    );
  }
}
